//
//  Manager.m
//  PrintJob
//
//  Created by blank on 2017/5/6.
//  Copyright © 2017年 CYN. All rights reserved.
//

#import "Manager.h"
#import "Employee.h"
#import "PrintNotification.h"

@interface Manager () <EmployeePrintDelegate>

@end

@implementation Manager

+ (Manager *)instance {
    static Manager *_instance = nil;

    @synchronized (self) {
        if (_instance == nil) {
            _instance = [[self alloc] init];
        }
    }

    return _instance;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(celebratePringDone)
                                                     name:NOTIF_DONE_PRINT_TASK
                                                   object:nil];
    }

    return self;
}


- (void)celebratePringDone {
    NSLog(@"celebrate print done");
}

- (void)beginPrintTask {

#if 0
    [[Employee instance] setDelegate:self];
    [[Employee instance] doPrintJob];

#else
   [[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_BEGIN_PRINT_TASK object:nil];

#endif

}

- (void)printJobDone {
    [self celebratePringDone];
}


@end
